package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzXqjd;
import com.ruoyi.system.service.IDzXqjdService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 小区解读Controller
 * 
 * @author ruoyi
 * @date 2023-09-07
 */
@RestController
@RequestMapping("/system/xqjd")
public class DzXqjdController extends BaseController
{
    @Autowired
    private IDzXqjdService dzXqjdService;

    /**
     * 查询小区解读列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzXqjd dzXqjd)
    {
        startPage();
        List<DzXqjd> list = dzXqjdService.selectDzXqjdList(dzXqjd);
        return getDataTable(list);
    }

    /**
     * 导出小区解读列表
     */
    @Log(title = "小区解读", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzXqjd dzXqjd)
    {
        List<DzXqjd> list = dzXqjdService.selectDzXqjdList(dzXqjd);
        ExcelUtil<DzXqjd> util = new ExcelUtil<DzXqjd>(DzXqjd.class);
        util.exportExcel(response, list, "小区解读数据");
    }

    /**
     * 获取小区解读详细信息
     */
    @GetMapping(value = "/{jdId}")
    public AjaxResult getInfo(@PathVariable("jdId") Long jdId)
    {
        return AjaxResult.success(dzXqjdService.selectDzXqjdByJdId(jdId));
    }

    /**
     * 新增小区解读
     */
    @Log(title = "小区解读", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzXqjd dzXqjd)
    {
        return toAjax(dzXqjdService.insertDzXqjd(dzXqjd));
    }

    /**
     * 修改小区解读
     */
    @Log(title = "小区解读", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzXqjd dzXqjd)
    {
        return toAjax(dzXqjdService.updateDzXqjd(dzXqjd));
    }

    /**
     * 删除小区解读
     */
    @Log(title = "小区解读", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jdIds}")
    public AjaxResult remove(@PathVariable Long[] jdIds)
    {
        return toAjax(dzXqjdService.deleteDzXqjdByJdIds(jdIds));
    }
}
